/**
* webplayer
* Author: Feil.Wang
* Date: 2013.07 
*/

;(function(window,undefined){
	
	window.webplyaer = {
		winWidth : "",
		winHeight : "",
		
		init : function(){
			this.winWidth = $(document.body).width();
			this.winHeight = $(document.body).height();
			this.bgReSize();
			this.pptSize();
			this.outlineSize();
			this.qaSize();
			this.videoSize();
			this.chatSize();
		},
		bgReSize : function(){
			
			$("#bgImg").css({
				"width" : this.winWidth,
				"height" : this.winHeight
			});
		},
		pptSize : function(){
			$(".ppt-container").css({
				"width" : this.winWidth*700/1440,
				"height" : this.winHeight-157,
				"left" : this.winWidth*330/1440,
				"top" : 40
			});
			$(".ppt-main").css({
				"height" : (this.winHeight-157)-111
			})
		},
		outlineSize : function(){
			$(".outline-container").css({
				"width" : this.winWidth*320/1440,
				"height" : this.winHeight - this.winWidth*260/1440 -221,
				"left" : this.winWidth*1050/1440,
				"top" : this.winWidth*260/1440 + 104
			});
			$(".outline-list").css({
				"height" : this.winHeight - this.winWidth*260/1440 -273
			});
		},
		qaSize : function(){
			$(".qa-container").css({
				"width" : this.winWidth*245/1440,
				"height" : this.winHeight -157,
				"left" : this.winWidth*65/1440,
				"top" : 40
			});
			$(".qa-list").css({
				"height" : this.winHeight -292
			});
		},
		videoSize : function(){
			$(".video-container").css({
				"width" : this.winWidth*320/1440,
				"height" : this.winWidth*240/1440+63,
				"left" : this.winWidth*1050/1440,
				"top" : 40
			});
			$(".player").css({
				"height" : this.winWidth*240/1440
			});
		},
		chatSize : function(){
			$(".chat-container").css({
				"width" : this.winWidth*320/1440,
				"height" : this.winHeight - this.winWidth*260/1440 -221,
				"left" : this.winWidth*1050/1440,
				"top" : this.winWidth*260/1440 + 104
			});
			$(".chat-cnt").css({
				"height" : this.winHeight - this.winWidth*260/1440 - 355
			});
		}
	}

})(window);

$(function(){

	webplyaer.init();
	$(window).resize(function(e){
		if(e.target == window){
			webplyaer.init();
		}
	});
	
	//表情
	$(".phiz-group").hover(function(){
		$(this).addClass("phiz-group-cur");
		$(this).children("ul").show();
	},function(){
		$(this).removeClass("phiz-group-cur");
		$(this).children("ul").hide();
	});
	
	//选择聊天对象
	$(".select-box").click(function(){
		if($(".select-option").css("display")=="none"){
			$(".select-option").slideDown(function(){
				$(this).css("overflow","auto")
			});
		}else{
			$(".select-option").slideUp();
		}
	});
	$(".select-option li").click(function(e){
		var name = $(this).text();
		$("#selectedName").text(name)
		$(".select-option").slideUp();
		e.stopPropagation()
	});
	
	$(document.body).click(function(e){
		var target = $(e.target);
		if(target.closest(".select-box").length == 0){
			$(".select-option").slideUp();
		}
		if(target.closest(".shortcut-1").length == 0){
			$(".quick-layout-tips").animate({
				"width" : "0px"
			},300);
		}
	});
	
	//窗口拖拽
	$( ".main > div" ).draggable({
		handle: ".comm-title",
		cursor: "move",
		stack: ".main > div"
	});
	//窗口大小调整
	$( ".ppt-container,.qa-container,.video-container,.chat-container,.outline-container" ).resizable();
	
	//模拟播放、暂停
	$("#playBtn").toggle(function(){
		$(this).attr("class","btn-pause");
	},function(){
		$(this).attr("class","btn-play");
	});
	//模拟静音
	$("#soundBtn").toggle(function(){
		$(this).attr("class","horn-off-icon");
	},function(){
		$(this).attr("class","horn-icon");
	});
	
	//音量滑块
	$( "#volSlider" ).slider({
		value: 50,
		change: function() {
			$( "#volSlider span" ).width($( "#volSlider a" ).css("left"));
		}
	});
	
	
});
//打开快速布局工具条
function openLayoutBar(){
	var $bar = $(".quick-layout-tips");
	if($bar.width()==0){
		$bar.animate({
			"width" : "240px"
		},300);
	}else if($bar.width()==240){
		$bar.animate({
			"width" : "0px"
		},300);
	}
}

//遮罩显示
function coverLayerShow(){
	$("#coverLayer").show().css("z-index","990");
}
//遮罩隐藏
function coverLayerHide(){
	$("#coverLayer").hide();
}

//显示点名窗口
function callName(){
	$(".callname-container").show().css("z-index","999");
	coverLayerShow();
}
//隐藏点名窗口
function callNameClose(){
	$(".callname-container").hide();
	coverLayerHide();
}
//显示抽奖窗口
function lotteryShow(){
	$(".lottery-container").show().css("z-index","999");
	lottery();//模拟抽奖
}
//隐藏抽奖窗口
function lotteryClose(){
	$(".lottery-container").hide();
}
//显示附件窗口
function accessoryShow(){
	$(".accessory-container").show().css("z-index","999");
}
//隐藏附件窗口
function accessoryClose(){
	$(".accessory-container").hide();
}
//显示投票调查窗口
function voteShow(){
	$(".vote-container").show().css("z-index","999");
	coverLayerShow();
}
//隐藏投票调查窗口
function voteClose(){
	$(".vote-container").hide();
	coverLayerHide();
}

//模拟抽奖
function lottery(){
	setTimeout(function(){
		$(".lottery-animate").hide();
		$("#lotteryOwner").show();
	},3000)
}

